addEvent('cmta_spalanie:sendFuelData', true)
addEventHandler('cmta_spalanie:sendFuelData', getResourceRootElement(), function(data)
    if not data then return end 
    local vehicle = getPedOccupiedVehicle(client)
    if not vehicle then return end 
    if client ~= getVehicleController(vehicle) then return end 
    if not getElementData(vehicle, 'vehicle:data') then return end 
    setElementData(vehicle, 'vehicle:data', data)
end)

addEvent('cmta_spalanie:interactVehicle', true)
addEventHandler('cmta_spalanie:interactVehicle', getResourceRootElement(), function(type, bool)
    local vehicle = getPedOccupiedVehicle(client)
    if type == 'engine' and vehicle then 
        setVehicleEngineState(vehicle, bool)
    end
end)

function displayVehicleLoss(loss)
    local thePlayer = getVehicleOccupant(source)
    local vehicleHealth = getElementHealth(source)
    if vehicleHealth-loss <= 350 then 
        setElementHealth(source, 355)
        return 
    end
    if loss >= 120 then 
        setVehicleEngineState(source, false)
    end
end
addEventHandler("onVehicleDamage", root, displayVehicleLoss)